package com.example.demo.controller;


import com.example.demo.service.ProductService;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.util.NamedList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author xiah
 * @since 2018-05-29
 */
@RestController
@RequestMapping("/product")
public class ProductController {
       @Autowired
       private ProductService productService;

       @RequestMapping("/getProduct")
       public SolrDocumentList getProduct(@RequestParam String search, Model model) throws Exception {
              return productService.getProduct(search);
       }

       @RequestMapping("/addProduct")
       public Object addProduct() throws Exception {
              productService.addProduct();
              return "ok";
       }

}
